package br.com.farmabid.persistence;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class ProdutorEntityManager {
	
	@Produces @ApplicationScoped
	public EntityManagerFactory getEntityManagerFactory(){
		return Persistence.createEntityManagerFactory("farmabid");
	}
	
	@Produces  
	@ApplicationScoped
    @DefaultEntityManager  
    public EntityManager createEntityManager(EntityManagerFactory factory) {
        return factory.createEntityManager();
    }
	
	@Produces
	@ApplicationScoped
    @TesteEntityManager  
    public EntityManager createEntityManagerTeste() {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("farmabidteste");
        return factory.createEntityManager();
    }
	
}